package com.qihoo.finance.fake.module.threadpool.dao;

import com.qihoo.finance.fake.module.threadpool.entity.ThreadPoolInfoEntity;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 读取线程池DB配置
 *
 * Created by zhaoliping on 2016/6/12.
 */
@Repository
public interface ThreadPoolInfoDao {
    /**
     * 获取对应系统模块的线程池配置
     * @param module 系统名或模块名
     * @return
     */
    @Select("        SELECT\n" +
            "          `poor_code` as name,\n" +
            "          `module` as module,\n" +
            "          `core_size` as coreSize,\n" +
            "          `max_size` as maxSize,\n" +
            "          `keep_alive` as threadKeepAliveTime,\n" +
            "          `queue_size` as queueSize,\n" +
            "          `policy` as policy\n" +
            "        FROM\n" +
            "          `thread_pool`\n" +
            "        WHERE (`module` = #{module} OR `module` IS NULL OR `module`= 'MSF' OR `module`= '') AND core_size > 0 AND max_size > 0 AND keep_alive > 0 AND queue_size > 0")
    List<ThreadPoolInfoEntity> queryThreadPoolInfoList(@Param("module") String module);

}
